/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.myapp.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 *
 * @author navneet
 */
public class ESAFB extends org.apache.struts.validator.ValidatorActionForm {
    private int     id;
    private int     groupId;
    private int     companyId;
    private String  siteName;
    private String  description;
    private String  error;

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    
    public String getSiteName() {
        return siteName;
    }

    public void setSiteName(String siteName) {
        this.siteName = siteName;
    }

    public int getCompanyId() {
        return companyId;
    }

    public void setCompanyId(int companyId) {
        this.companyId = companyId;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getError() {
        return error;
    }

    public void setError(String error) {
        this.error = error;
    }

    public int getGroupId() {
        return groupId;
    }

    public void setGroupId(int groupId) {
        this.groupId = groupId;
    }

    public ESAFB() {
        super();
        // TODO Auto-generated constructor stub
    }

    public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
        ActionErrors errors = new ActionErrors();
        if (getGroupId() < 1) {
            errors.add("groupId", new ActionMessage("error.ASAFB.groupId.required"));
        }
        if (getCompanyId() < 1) {
            errors.add("companyId", new ActionMessage("error.ASAFB.companyId.required"));
        }
        if (getSiteName() == null || getSiteName().length() < 1) {
            errors.add("siteName", new ActionMessage("error.ASAFB.siteName.required"));
        }
        return errors;
    }
}
